﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ERPStore.Extensions;

using Microsoft.Practices.Unity;

namespace ERPStore.Web.EventConsumers
{
	public class AppStartEventConsumer : EventBrokR.IConsumer<ERPStore.Events.ApplicationStartedEvent>
	{
		public void Handle(ERPStore.Events.ApplicationStartedEvent eventMessage)
		{
			var container = ERPStore.GlobalConfiguration.Configuration.DependencyResolver.GetContainer();
			var logger = container.Resolve<ERPStore.Logging.ILogger>();
			if (logger is ERPStore.Logging.DiagnosticsLogger)
			{
				container.RegisterType<ERPStore.Logging.ILogger, Logging.PushLogger>(new PerResolveLifetimeManager());
			}
		}
	}
}
